﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

using Microsoft.Practices.Unity;

namespace ERPStore.Web.IOC
{
	public class UnityControllerFactory : IControllerFactory
	{
		private IControllerFactory m_Controller;
		private IUnityContainer m_Container;

		public UnityControllerFactory(IUnityContainer container)
		{
			m_Controller = new DefaultControllerFactory();
			m_Container = container; 
		}

		#region IControllerFactory Members

		public IController CreateController(System.Web.Routing.RequestContext requestContext, string controllerName)
		{
			var controller = m_Controller.CreateController(requestContext, controllerName);
			return controller;
		}

		public System.Web.SessionState.SessionStateBehavior GetControllerSessionBehavior(System.Web.Routing.RequestContext requestContext, string controllerName)
		{
			return m_Controller.GetControllerSessionBehavior(requestContext, controllerName);
		}

		public void ReleaseController(IController controller)
		{
			m_Controller.ReleaseController(controller);
		}

		#endregion
	}
}
